<?php

namespace App\Http\Requests\Admin\AdminUser;

use App\Http\Requests\Request;

class StoreRequest extends Request
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * 验证规则
     *
     * @return array
     */
    public function rules()
    {
        return [
            'user_name' => 'required|unique:admin_user|max:16',
            'password' => 'required|confirmed:re_password',
            'role_id'=>'required|exists:admin_role,id'
        ];
    }

    /**
     * 验证信息
     * @return array
     */

    public function messages()
    {
        return [
            'user_name.required' => '请填写用户名',
            'user_name.unique'  => '用户名已存在',
            'user_name.max'  => '用户名必须小于16字符',
            'password.required'  => '请填写密码',
            'password.confirmed'  => '两次输入密码不一致',
            'role_id.required'=>'请选择用户组',
            'role_id.exists'=>'用户组不存在'
        ];
    }
}
